package com.ngc.mall.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ngc.mall.domain.MenuDomain;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface MenuMapper extends BaseMapper<MenuDomain> {

//    @Select("select * from menu where id in (select menu_id from role_menu where role_id in " +
//            "<foreach collection='roleIdList' item='item'  separator=',' >",
//            "(#{item})",
//            "</foreach>"
//            ")")

    @Select({  "<script>",
            "select * from menu where is_show = 1 and id in (select menu_id from role_menu where role_id in",
            "<foreach collection='roleIdList' item='item'  separator=',' >",
            "(#{item})",
            "</foreach>)",
            "</script>"})
    List<MenuDomain> findMenusByRoleIdList(List<Long> roleIdList);

}
